package com.yun.algorithmproblem.leetcode;

import java.util.ArrayList;
import java.util.HashMap;

public class Leetcode2176 {

	public int countPairs(int[] nums, int k) {
		int ans=0;
		HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
		for (int i = 0; i < nums.length; i++) {
			ArrayList<Integer> arrayList = map.getOrDefault(nums[i], new ArrayList<>());
			for (Integer j : arrayList) {
				if(i*j%k==0){
					ans++;
				}
			}
			arrayList.add(i);
			map.put(nums[i],arrayList);
		}
		return ans;
	}
}
